<i><%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
	<!DOCTYPE html>
	<html>
<head>
<meta charset="UTF-8">
<title>旅游表(游学) 编辑页面</title>
<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
	name="viewport">
<jsp:include page="../com/header.jsp"></jsp:include>
<script type="text/javascript" src="../../js/comm/editcomm.js"></script>
<script type="text/javascript" src="travelTable.js"></script>
<script type="text/javascript">
	$(function(){
		$("#saveOrupdate").click(function(){
			//封装图片路径 start
			var imgUrls = $('input[name=imgUrl]');
			var urls = "";//拼接后的图片路径
			for (var i = 0; i < imgUrls.length; i++) {
				var imgUrlInput = imgUrls[i];
				var imgUrl = imgUrlInput.value;
				urls += imgUrl + ",";
			}
			urls = urls.substring(0,urls.length-1)
			$('#tourImg').val(urls);
			//封装图片路径 end
			
			//比较定金和原价
			var reservationPrice = $('#reservationPrice').val();
			var travelItemPrice = $('#travelItemPrice').val();
			
			if(parseInt(reservationPrice) > parseInt(travelItemPrice)){
				myAlert('预定价格不能大于原价');
				return;
			}
			
			saveData(root + 'cms/travelTable/saveTravelTable','travelTableList.jsp');
		});
		var tId = getUrlParam("id");
		if (!tId) {
			myAlert('id参数不能为空');
			return;
		}
		$.ajax({
			url : root + 'cms/travelTable/findTravelTableById',
			type : 'post',
			dataType : 'json',
			data : {
				modelId : tId
			},
			success : function(data) {
				console.log(data);
				if (data.code == 1) {
					var contentHtml = $('#travelTableTmpl').render(data.object, {
						mydata : data
					});
					
					$('#travelTableContent').html(contentHtml);
					ue = UE.getEditor("route");
					ue.addListener("ready", function() {
						if (data.object.travelTable.route)
							ue.setContent(data.object.travelTable.route);
					});
					ue1 = UE.getEditor("cost");
					ue1.addListener("ready", function() {
						if (data.object.travelTable.cost)
						ue1.setContent(data.object.travelTable.cost);
					});
					ue2 = UE.getEditor("travelBrief");
					ue2.addListener("ready", function() {
						if (data.object.travelTable.travelBrief)
							ue2.setContent(data.object.travelTable.travelBrief);
					});
					
		            //时间选择框  
// 					$("#endTime").datetimepicker({format: 'yyyy-mm-dd hh:ii',minView: "hour",language : 'zh-CN',autoclose: true}).on('changeDate',function(ev){
		            $("#endTime").datetimepicker({format: 'yyyy-mm-dd',minView: "day",language : 'zh-CN',autoclose: true}).on('changeDate',function(ev){
		            	var starttime=$("#planStartTime").val();
		            	$("#endTime").datetimepicker('hide');
		            });
				}else{
					var contentHtml = $('#travelTableTmpl').render("");
					$('#travelTableContent').html(contentHtml);
				}
			}
		});
	});
</script>
</head>
<body>
	<section>
		<div>
			<div class="col-xs-12">
				<div class="box" style="height:1300px">
					<div class="box-header">
						<br> <input type="button" value="确定" id="saveOrupdate"
							class="btn btn-success">
						<input type="button" onclick="backAction('travelTableList.jsp');" class="btn btn-info" value="返回"/>
					</div>
					<form id="submit_form" class="form-horizontal">
						<div class="tab" id="travelTableContent"></div>
					</form>
				</div>
			</div>
		</div>
	</section>
	<script type="text/x-jsrender" id="travelTableTmpl">
			<fieldset> 
				<input type="hidden" id="tId" name="id" value="{{:travelTable.id}}" />
	        	{{!--<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">图片：</label>
       				 <div class="col-md-3">
						<div class="upload_div">
                        	<img id="myImageShow" src="../../{{:imgUrl}}" width="100px" height="100px" />
                        	<input type="hidden" id="imgUrl" name="imgUrl" value="{{:imgUrl}}"/>
                        	<input type="file" id="uploadPhotoFile" name="photoFile" class="upload_file">
                        </div>
					</div>
      			</div>--}}
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">项目名称：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写项目名称(50字以内)" class="form-control input-sm" data-rule="required;length[0~50]" id="travelItemName" name="travelItemName" value="{{:travelTable.travelItemName}}" />
					</div>
					<label class="col-md-2 control-label controls" for="formGroupInputSmall">项目地址：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写项目地址" class="form-control input-sm" data-rule="required;length[0~250]" id="travelItemAddress" name="travelItemAddress" value="{{:travelTable.travelItemAddress}}" />
					</div>
      			</div>
				<div class="form-group">
					<label class="col-md-2 control-label controls" for="formGroupInputSmall">标语：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写标语" class="form-control input-sm" data-rule="required;length[0~255]" id="slogan" name="slogan" value="{{:travelTable.slogan}}" />
					</div>
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">项目价格：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写项目价格" class="form-control input-sm" data-rule="required;length[0~50];money" id="travelItemPrice" name="travelItemPrice" value="{{:travelTable.travelItemPrice}}" />
					</div>
      			</div>
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">联系电话：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写联系电话" class="form-control input-sm" datatype data-rule="required;length[0~50];tel || mobile" id="travelItemTelephone" name="travelItemTelephone" value="{{:travelTable.travelItemTelephone}}" />
					</div>
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">排序值：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写排序值" class="form-control input-sm" data-rule="length[1~10];plus" maxlength="10" id="sort" name="sort" value="{{:travelTable.sort}}" />
					</div>
      			</div>

				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">最低组团人数：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写最低组团人数" class="form-control input-sm" data-rule="required;length[0~255]" id="minGroupPeople" name="minGroupPeople" value="{{:travelTable.minGroupPeople}}" />
					</div>
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">预计出发日期：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写预计出发日期" class="form-control input-sm"  id="endTime" name="planStartTime" value="{{:travelTable.planStartTime}}" />
					</div>
      			</div>
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">预订价格 ：</label>
       				 <div class="col-md-3">
						<input type="text" placeholder="请填写预订价格 " class="form-control input-sm" data-rule="required;length[0~255]" id="reservationPrice" name="reservationPrice" value="{{:travelTable.reservationPrice}}" />
					</div>
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">项目种类 ：</label>
       				 <div class="col-md-3">
						<select class="form-control input-sm" id="travelItemType" name="travelItemType" data-rule="required" >
                          <option  value="">请选择</option>
                          <option  value="1" {{if travelTable.travelItemType=="1"}}selected{{/if}}>国内</option>
                          <option  value="2" {{if travelTable.travelItemType=="2"}}selected{{/if}}>国外</option>
                        </select>
					</div>
      			</div>
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">游学图片：</label>
       				 <div class="col-md-9" id="imgDiv">
						{{for tourList}}
							<div class="upload_div" style="float: left; margin-right: 15px;">
								<img id="myImageShow{{:#index+1}}" src="../..{{:}}" width="100px" height="100px" />
								<input type="hidden" id="imgUrl{{:#index+1}}" name="imgUrl" value="{{:}}"/>
								<input type="file" id="uploadPhotoFile{{:#index+1}}" name="photoFile" class="upload_file" data-type="' + type + '">
							</div>
                        {{/for}}
						<input type="hidden" id="tourImg" name="tourImg"/>
						<img src="../../image/add.png"  class="add_img" style="cursor:pointer;" data-type="0">
						<img src="../../image/jian.png" class="del_img" style="cursor:pointer;" data-type="0">
					</div>
      			</div>
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">简介（富文本）：</label>
						{{!--<input type="text" placeholder="请填写简介（富文本）" class="form-control input-sm" data-rule="required;length[0~5000]" id="route" name="route" value="{{:travelTable.route}}" />--}}
					<div class="col-md-9" id="travelBrief" name="travelBrief" style="height:150px;"></div>
      			</div>
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">行程说明（富文本）：</label>
						{{!--<input type="text" placeholder="请填写行程说明（富文本）" class="form-control input-sm" data-rule="required;length[0~5000]" id="route" name="route" value="{{:travelTable.route}}" />--}}
					<div class="col-md-9" id="route" name="route" style="height:150px;"></div>
      			</div>
				<div class="form-group">
        			<label class="col-md-2 control-label controls" for="formGroupInputSmall">费用须知（富文本）：</label>
						{{!--<input type="text" placeholder="请填写费用须知（富文本）" class="form-control input-sm" data-rule="required;length[0~2000]" id="cost" name="cost" value="{{:travelTable.cost}}" />--}}
					<div class="col-md-9" id="cost" name="cost" style="height:150px;"></div>
      			</div>
			</fieldset>
	</script>
</body>
	</html></i>